var a = getApp();

Page({
    data: {
        active: 0,
        info: {},
        list: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        language: ""
    },
    onLoad: function(a) {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.recommender.api.index.index");
        e += "&state=" + this.data.active, a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    info: e.data,
                    list: e.data.list.data,
                    isLoadMore: !0,
                    page: 1,
                    total_page: e.data.list.last_page
                }), wx.setNavigationBarTitle({
                    title: e.data.custom_name
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    onChange: function(a) {
        this.data.active = a.detail.index, this.getData();
    },
    gotoDetail: function(a) {
        var t = a.target.dataset.id || a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageE/others/referral_officerDetail/referral_officerDetail?id=" + t
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    _getMoreData: function() {
        var t = this, e = {}, o = "", i = "";
        t.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        o = "plugin.recommender.api.index.index", e = {
            page: t.data.page,
            state: t.data.active
        }, i = a.getNetAddresss(o), a._postNetWork({
            url: i,
            showToastIn: !1,
            data: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    isLoadMore: !0,
                    list: t.data.list.concat(e.data.list.data)
                }) : t.setData({
                    page: t.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        }));
    },
    onShareAppMessage: function() {}
});